package com.qymerge.manage.base.service.impl;

import com.qymerge.manage.base.dao.IMetaMaterialDao;
import com.qymerge.manage.base.ro.MetaMaterialRO;
import com.qymerge.manage.base.service.IMetaMaterialService;
import com.qymerge.manage.core.bean.DataTableRO;
import com.qymerge.manage.core.bean.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>Title: MetaAccountViewServiceImpl</p>
 * <p>Description: 科目</p>
 *
 * @author Xiao
 * @date 2025/4/29 18:43
 * @version 1.0.0
 */
@Service
public class MetaMaterialServiceImpl implements IMetaMaterialService {

    @Autowired
    private IMetaMaterialDao metaMaterialDao;

    /**
     * 用户管理-查询
     *
     * @param ro
     * @param pageRequest
     * @return
     */
    @Override
    public DataTableRO list(MetaMaterialRO ro, PageRequest pageRequest) {
        List list = metaMaterialDao.list(ro, pageRequest);
        DataTableRO dataTableRO = new DataTableRO();
        int allCount = metaMaterialDao.total(ro);
        int pageSize = pageRequest.getSize();
        dataTableRO.setAll_count(allCount);
        dataTableRO.setList(list);
        dataTableRO.setCurrent_page(pageRequest.getPage());
        dataTableRO.setPage_size(pageSize);
        int allPage = (allCount % pageSize == 0 ? allCount / pageSize : allCount / pageSize + 1);
        dataTableRO.setAll_page(allPage);
        return dataTableRO;
    }

    /**
     * 详情
     *
     * @param id
     * @return
     */
    @Override
    public MetaMaterialRO detail(String id) {
        return metaMaterialDao.findOne(id);
    }


}
